/*
 * @Description: 赋权申请
 * @Author: Zzt
 * @Date: 2023-02-02 16:24:14
 * @LastEditTime: 2023-02-03 17:39:40
 */
import request from '@/utils/request';
import type { IPageQuery, ICoordinate } from '@/interfaces/global';

/* 
赋权申请单
*/
/* 新增任务 */
export interface IAddRightApplyParams {
  applyForm?: ApplyForm;
  archiveItemList?: ArchiveItemList[];
}
export interface ApplyForm {
  applyFormNo?: string;
  applyTime?: string;
  archiveTypeName?: string;
  description?: string;
  endTime?: string;
  fondsName?: string;
  id?: number;
  processInstanceId?: string;
  proposer?: string;
  purpose?: string;
  realUser?: string;
  status?: number;
  title?: string;
  useDay?: number;
  useTypeElectronicRights?: string;
  useTypeElectronicRightsList?: any[];
  useTypeEntity?: string;
  userId?: number;
}

export interface ArchiveItemList {
  applyFormId?: number;
  archiveItemId?: number;
  archiveNo?: string;
  archiveTypeName?: string;
  atCode?: number;
  atType?: number;
  departmentName?: string;
  fondsName?: string;
  id?: number;
  level?: number;
  secret?: string;
  title?: string;
}

export function addRightApply(data: IAddRightApplyParams) {
  return request({
    url: '/rights-apply-form/',
    method: 'post',
    data
  });
}
// /* 查询 */
export function fetchRightApply(params: IPageQuery) {
  return request({
    url: '/rights-apply-form/page',
    method: 'get',
    params
  });
}

/* 通过id查询 */
export function fetchRightApplyById(id: number) {
  return request({
    url: `/rights-apply-form/${id}`,
    method: 'get'
  });
}
/* 根据processInstanceId查询 */
export function fetchApplyByInstanceId(params: { id?: number }) {
  return request({
    url: '/rights-apply-form/processInstanceId',
    method: 'get',
    params
  });
}

/* 根据applyFormNo查询 */
export function fetchRightApplyByFormNo(applyFormNo?: string) {
  return request({
    url: `/rights-apply-form/applyFormNo/${applyFormNo}`,
    method: 'get'
  });
}
